 <script type="text/javascript" src="/scripts/tabsheets.js"></script>   
              <?  
              function pluralForm($n, $form1, $form2, $form5)  
              {  
              $n = abs($n) % 100;  
              $n1 = $n % 10;  
              if ($n > 10 && $n < 20) return $form5;  
              if ($n1 > 1 && $n1 < 5) return $form2;  
              if ($n1 == 1) return $form1;  
              return $form5;  
              }  
              ?>
              
              
          
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="">
        <tr>
          <td width="16%">&nbsp;</td>
          <td width="80%"><h1>Оформление заказа</h1></td>
      </tr>
    </table>
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class=""  style="margin-top:1.2em">
        <tr>
          <td width="16%">&nbsp;</td>
          <td width="48%" valign="top">
               <? if($this->session->userdata('logged_in')) { 
                //Если пользователь залогинен 
 
                $username=$this->session->userdata('id');
                $user = $this->db->query("SELECT * FROM users WHERE id='$username' LIMIT 1");
                
                $data['user']=$user->row();
                
                $this->load->view('/store/forms/if_login', $data);
                
                }else{
                 $this->load->view('/store/forms/if_no_login', $data);
            
              }?>
          
          
          </td>
          <td width="32%" valign="top" align="center">
              
          
              <table width="80%" border="0" cellspacing="0" cellpadding="0" style="background-color:#EFEDD9">
          
              <?	foreach ($query->result() as $add){ 
                  $father = $this->db->query("SELECT father,article,price, id FROM articles WHERE id='$add->store' LIMIT 1");
              		$father = $father->row();
  
                  $store = $this->db->query("SELECT name,title,father,id FROM store WHERE id='$father->father' LIMIT 1");
              		$store = $store->row();
              ?>  
              
              <tr>
              <td style="padding:10px 10px 5px 10px" align="left">
                <small><b><?=$store->title?></b><br>Артикул: <?=$father->article?></small>
              </td>
              <td align="right" valign="top" style="padding:10px 10px 5px 10px"><small><?=$add->quantity?></small></td>     
              </tr>
                
              <? $kol=$add->quantity + $kol;
              
              $price=($add->price * $add->quantity)+$price;
              
              ?>
              
              
                
              <?}?>
              
               <? $price_ = number_format($price, 0, ',', ' ');?>
              
             <tr>
                <td colspan="2" style="padding:0 10px 0 10px" >
                <hr size="1" style="margin:5px 0 5px 0">
                </td>
              </tr>
              
              <tr>
                <td colspan="2" style="padding:0px 15px 5px 15px" align="left">
                <div><?=$kol?> <?=pluralForm($kol, "товар", "товара", "товаров") ?> на сумму <b><?=$price_?> грн</b></div>
                
                
                <? if($price < 400){ ?>
                <br><div><font color="red">+ 30 грн за доставку</font></div>
                <div><small><i>При стоимости заказа свыше 400 грн, доставка осуществляется бесплатно</i></small></div> 
                <? } ?>

                </td>
              </tr>
              
              <tr>
                <td colspan="2" align="center" style="padding:10px 10px 10px 10px">
                <input type="button" value="Изменить заказ" onclick="window.location = '/store/add/'">
                </td>
              </tr>
              
              </table>
        
          
          </td>
      </tr>
    </table>